/*
 *
 *  * Copyright (c) 2016. For Intelligent Group.
 *
 */

package com.intelligent.ispc.r.analysis;

import com.intelligent.ispc.constant.AppConstant;
import com.intelligent.ispc.r.analysis.grr.GrrAnovaAndSourceCommand;
import com.intelligent.ispc.r.analysis.grr.GrrChartDataCommand;
import com.intelligent.ispc.r.analysis.grr.GrrSummaryCommand;
import com.intelligent.ispc.r.analysis.spc.CCCommand;
import com.intelligent.ispc.r.analysis.spc.NDCommand;
import com.intelligent.ispc.r.analysis.spc.ScatterCommand;
import com.intelligent.ispc.utils.ApplicationPathUtil;

/**
 * R command build factory.
 */
public class RCommandFactory {

    public static final String R_SCRIPT_DIR = "rscripts";
    public static final String R_SCRIPT_SPC_ND = "analysis_NormalDistribution.R";
    public static final String R_SCRIPT_SPC_SCATTER = "analysis_Scatter.R";
    public static final String R_SCRIPT_SPC_XBAR = "analysis_ControlMean.R";
    public static final String R_SCRIPT_SPC_MR = "analysis_ControlMoveRange.R";
    public static final String R_SCRIPT_SPC_R = "analysis_ControlRange.R";
    public static final String R_SCRIPT_SPC_RUN = "analysis_ControlRun.R";
    public static final String R_SCRIPT_SPC_SD = "analysis_ControlStd.R";
    public static final String R_SCRIPT_GRR_DATA = "grr_analysis.R";
    public static final String R_SCRIPT_GRR_PLOT = "grr_analysis_plot.R";

    /**
     * Create ND command instance.
     *
     * @return NDCommand
     */
    public static NDCommand createNDCommand() {
        String path = ApplicationPathUtil.getPath(R_SCRIPT_DIR, R_SCRIPT_SPC_ND);
        return new NDCommand(path);
    }

    /**
     * Create scatter command instance.
     *
     * @return ScatterCommand
     */
    public static ScatterCommand createScatterCommand() {
        String path = ApplicationPathUtil.getPath(R_SCRIPT_DIR, R_SCRIPT_SPC_SCATTER);
        return new ScatterCommand(path);
    }

    /**
     * Create Run command instance.
     *
     * @return CCCommand
     */
    public static CCCommand createRunCommand() {
        String path = ApplicationPathUtil.getPath(R_SCRIPT_DIR, R_SCRIPT_SPC_RUN);
        return new CCCommand(path, AppConstant.CHART_TYPE_SPC_RUN);
    }

    /**
     * Create SD command instance.
     *
     * @return CCCommand
     */
    public static CCCommand createSDCommand() {
        String path = ApplicationPathUtil.getPath(R_SCRIPT_DIR, R_SCRIPT_SPC_SD);
        return new CCCommand(path, AppConstant.CHART_TYPE_SPC_SD);
    }

    /**
     * Create RC command instance.
     *
     * @return CCCommand
     */
    public static CCCommand createRCommand() {
        String path = ApplicationPathUtil.getPath(R_SCRIPT_DIR, R_SCRIPT_SPC_R);
        return new CCCommand(path, AppConstant.CHART_TYPE_SPC_R);
    }

    /**
     * Create XBar command instance.
     *
     * @return CCCommand
     */
    public static CCCommand createXBarCommand() {
        String path = ApplicationPathUtil.getPath(R_SCRIPT_DIR, R_SCRIPT_SPC_XBAR);
        return new CCCommand(path, AppConstant.CHART_TYPE_SPC_XBAR);
    }

    /**
     * Create MR command instance.
     *
     * @return CCCommand
     */
    public static CCCommand createMRCommand() {
        String path = ApplicationPathUtil.getPath(R_SCRIPT_DIR, R_SCRIPT_SPC_MR);
        return new CCCommand(path, AppConstant.CHART_TYPE_SPC_MR);
    }

    /**
     * Create Anova & Source command instance.
     *
     * @return GrrAnovaAndSourceCommand
     */
    public static GrrAnovaAndSourceCommand createGrrAnovaAndSourceCommand() {
        String path = ApplicationPathUtil.getPath(R_SCRIPT_DIR, R_SCRIPT_GRR_DATA);
        return new GrrAnovaAndSourceCommand(path);
    }

    /**
     * Create Chart Details command instance.
     *
     * @return GrrChartDataCommand
     */
    public static GrrChartDataCommand createGrrChartDataCommand() {
        String path = ApplicationPathUtil.getPath(R_SCRIPT_DIR, R_SCRIPT_GRR_PLOT);
        return new GrrChartDataCommand(path);
    }

    /**
     * Create Summary command instance.
     *
     * @return GrrSummaryCommand
     */
    public static GrrSummaryCommand createGrrSummaryCommand() {
        String path = ApplicationPathUtil.getPath(R_SCRIPT_DIR, R_SCRIPT_GRR_DATA);
        return new GrrSummaryCommand(path);
    }
}
